<template>
    <div>
        <TemplateCenter :center="templateList"></TemplateCenter>
    </div>
</template>

<script>
// import request from 'request'
import TemplateCenter from '@/components/createdesign/TemplateCenter'
export default {
    components: {
        TemplateCenter
    },
    async asyncData({app, $axios, isDev,route, store, env, params, query, req, res, redirect, error}) {
		let templateList = null,Label = null;
		var templateParam = {  // 获取模板参数
			ProductCategorieNum: query.n,
			ProductTypeId: query.id,
			SizeId: '',
			pageIndex: 1,
			pageSize: 19,
			SortOrder: 0,
			ChargingMode: '',
			StrFilterValue: '',
			TeamNum: '',
			keywords: query.k
		}
		// var formData = new FormData();
		var str = ''
		for (let key in templateParam) {
			str += `${key}=${templateParam[key]}&`
		}
		let [center,label] = await Promise.all([
			$axios.post('/TemplateCenter', str),
			$axios.get('/AllTemplateClassification')
		])
		templateList = center.data;
		Label = label.data;
		Label.forEach((item) => {
			item.ProductTypeList.forEach((tmp) => {
				if(tmp['TypeId'] == query.id) {
					query.subtitle = tmp['TypeName']
				}
			})
		})
		templateList.Data.unshift({})
		// console.log(templateList, '服务端')
		return {
      templateParam,
			templateList,
			query: query,
			Label
		}
	},
	fetch() {
		// console.log(123213)
	},
	head() {
		return {
			title: `免费${this.query.subtitle}模板列表_海量免费纸质名片模板无限制使用_免费下载${this.query.subtitle}高清无水印文件_阿里印`
		}
	},
    mounted() {
        this.$setTheme(this.$store)
		console.log(this.templateList,'模板列表')
		// console.log(this.Label, '产品类别')
        // console.log(this.templateParam,this.templateList)
	}
}
</script>

<style lang="less" scoped>

</style>
